package com.zxjbyte.yiyi.server.modifier;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 一键魔改，只需三个参数就可以魔改出一个完全符合您公司结构的项目
 *
 * 所谓一键既约定大于配置
 * @Author zhangxingjia
 * @Date 2023/3/27 16:22
 * @Version: 1.0
 */
public class QuickProjectModifier {

    /**
     * 以下是一键魔改需要配置的三个参数
     * 域名部分1, 域名部分2，项目名
     *  例如 :
     *  域名部分1 = com （公司一级域名）
     *  域名部分2 = baidu (公司名)
     *  项目名 = crm
     */
    private static final String domainName1 = "com";
    private static final String domainName2 = "baidu";
    private static final String projectName = "crm";



    //=========================分割线，固定参数勿动==============================

    // ========================old ===========================
    public static final String groupId = "com.zxjbyte";
    public static final String artifactId1 = "yiyi-boot";
    public static final String artifactId2 = "yiyi-";
    public static final String packageName = "com.zxjbyte.yiyi";
    public static final String classKeyWords = "Yiyi";


    // ========================new===========================
    public static final String newGroupId = domainName1 + "." + domainName2;
    public static final String newArtifactId1 = domainName2 + "-" + projectName;
    public static final String newArtifactId2 = domainName2 + "-";
    public static final String newPackageName = domainName1 + "." + domainName2 + "." + projectName;
    public static final String newProjectDir = domainName2 + "-" + projectName;
    public static final String newClassKeyWords = StrUtil.upperFirst(QuickProjectModifier.domainName2);

    public static List<String[]> lastKeyWords(){
        List<String[]> list = new ArrayList<>();
        list.add(new String[] {"yiyi", domainName2});
        list.add(new String[] {"YIYI-BOOT", domainName2.toUpperCase() + "-" + projectName.toUpperCase()});
        list.add(new String[] {"YIYI_BOOT", domainName2.toUpperCase() + "_" + projectName.toUpperCase()});
        return list;
    }


    public static void main(String[] args) {
        Date now = new Date();
        before(now);
        ProjectModifier.run();
        after(now);
    }


    private static void after(Date now){
        System.out.println("一键魔改项目完成，共耗时："+ (DateUtil.spendMs(now.getTime()))  +" 毫秒");
    }

    private static void before(Date now){
        System.out.println("================================================");
        System.out.println("======= 欢迎使用YIYI-BOOY项目一键魔改工具 =========");
        System.out.println("================================================");
        System.out.println();
        System.out.println("一键项目魔改执行开始，当前时间 [" + DateUtil.formatDateTime(now) + "]");
        System.out.println();
    }
}
